// 
// Copyright 2010 Classpath Pty Ltd <opensource@classpath.com.au>
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 

**
** Represents the ability to use a table option from within part of a table change.
**
mixin CanUseTableOptions : HasModifications {

    **
    ** Creates a `CheckTableOption` for use as a `TableOption` and stores it in the table options being tracked by the mixed in class.
    **
    CheckTableOption check(Str name, Str check) {
        Pod.of(this).log.debug("${typeof}.check(${name}, ${check}) - start")
        option := CheckTableOption(name, check)
        modifications.add(option)
        Pod.of(this).log.debug("${typeof}.check(${name}, ${check}) - end - returning ${option}")
        return option
    }

    **
    ** Creates a `ForeignKeyTableOption` for use as a `TableOption` and stores it in the table options being tracked by the mixed in class.
    **
    ForeignKeyTableOption foreignKey(Str name, Str[] columns, Reference reference) {
        Pod.of(this).log.debug("${typeof}.foreignKey(${name}, ${columns}, ${reference}) - start")
        option := ForeignKeyTableOption(name, columns, reference)
        modifications.add(option)
        Pod.of(this).log.debug("${typeof}.foreignKey(${name}, ${columns}, ${reference}) - end - returning ${option}")
        return option
    }

    **
    ** Creates a `IndexTableOption` for use as a `TableOption` and stores it in the table options being tracked by the mixed in class.
    **
    IndexTableOption index(Str name, Str[] columns) {
        Pod.of(this).log.debug("${typeof}.index(${name}, ${columns}) - start")
        option := IndexTableOption(name, columns)
        modifications.add(option)
        Pod.of(this).log.debug("${typeof}.index(${name}, ${columns}) - end - returning ${option}")
        return option
    }

    **
    ** Creates a `PrimaryKeyTableOption` for use as a `TableOption` and stores it in the table options being tracked by the mixed in class.
    **
    PrimaryKeyTableOption primaryKey(Str name, Str[] columns) {
        Pod.of(this).log.debug("${typeof}.primaryKey(${name}, ${columns}) - start")
        option := PrimaryKeyTableOption(name, columns)
        modifications.add(option)
        Pod.of(this).log.debug("${typeof}.primaryKey(${name}, ${columns}) - end - returning ${option}")
        return option
    }

    **
    ** Creates a `Reference` for use in a `ForeignKeyTableOption`.
    **
    Reference references(Str name, Str[] columns) {
        Pod.of(this).log.debug("${typeof}.references(${name}, ${columns}) - start")
        reference := Reference(name, columns)
        Pod.of(this).log.debug("${typeof}.references(${name}, ${columns}) - end - returning ${reference}")
        return reference
    }

    **
    ** Creates a `UniqueTableOption` for use as a `TableOption` and stores it in the table options being tracked by the mixed in class.
    **
    UniqueTableOption unique(Str name, Str[] columns) {
        Pod.of(this).log.debug("${typeof}.unique(${name}, ${columns}) - start")
        option := UniqueTableOption(name, columns)
        modifications.add(option)
        Pod.of(this).log.debug("${typeof}.unique(${name}, ${columns}) - end - returning ${option}")
        return option
    }

}
